﻿@model string
@{
    Style.Reqiured("codemirror").AtHead();
    Script.Reqiured("codemirror").AtFoot();
    //string value = Html.Raw(Model).ToString();
    //value = System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(value);
    string name = ViewData.TemplateInfo.GetFullHtmlFieldName("");
    var descriptor = ViewData.ModelMetadata.GetViewDescriptor();

    if (descriptor != null && !descriptor.Properties.ContainsKey("rows"))
    {
        descriptor.Properties.Add("rows", "5");
    }
}
@Html.TextArea("", Model, descriptor?.ToHtmlProperties())
@using (Script.AtFoot())
{
    <script type="text/javascript">
        var editor = CodeMirror.fromTextArea(document.getElementById('@name'), {
            lineNumbers: true,
            mode: "htmlmixed",
            theme: 'monokai',
            lineWrapping: true,
            autofocus: true,
            tabSize: 2,
            extraKeys: { "Ctrl-J": "autocomplete" },
            autoCloseTags: true
        });
    </script>
}
